﻿@page
@model Web.Pages.PModel
@{

}
<link href="https://vjs.zencdn.net/8.3.0/video-js.css" rel="stylesheet" />
<div class="container text-center">
    <video id="my-video" class="video-js" controls preload="auto" data-setup="{}">
        <p class="vjs-no-js">
            To view this video please enable JavaScript, and consider upgrading to a
            web browser that
            <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
        </p>
    </video>
    <form method="post" style="margin-top:10px;">
        <input asp-for="Data.PId" type="text" class="form-control" id="exampleInputPId" hidden>
        <input asp-for="Data.Url" type="text" class="form-control" id="exampleInputUrl" hidden>
        <input asp-for="Data.Name" type="text" class="form-control" id="exampleInputName" hidden>
        <input asp-for="Data.DataMsg" type="text" class="form-control" id="exampleInputDataMsg" hidden>
        <input asp-for="Data.MUrl" type="text" class="form-control" id="exampleInputMUrl" hidden>
        @if (!string.IsNullOrEmpty(Model.Data?.PId) && Model.Data.PId != "0")
        {
            <input type="submit" class="form-control btn btn-primary" value="加速播放">
        }

    </form>
</div>




<script src="https://vjs.zencdn.net/8.3.0/video.min.js"></script>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script type="text/javascript">
    $(function(){
            var default_hls_address = '@ViewData["data"]';
        var options = {
            autoplay: true,
            controls: true,
            loop: true,
            preload: 'auto',
            sourceOrder: true,
            sources: [{
                src: default_hls_address,
                type: 'application/x-mpegURL'
            }, {
                src: '',
                type: 'video/webm'
            }],
            techOrder: ['html5'],
            flash: {
                swf: ''
            }
        }
        var video = videojs('my-video', options);
        video.on(['loadstart', 'play', 'playing', 'firstplay', 'pause', 'ended', 'adplay', 'adplaying', 'adfirstplay', 'adpause', 'adended', 'contentplay', 'contentplaying', 'contentfirstplay', 'contentpause', 'contentended', 'contentupdate'], function (e) {

        });
        window.onbeforeunload = (e) => {
            video.dispose();
        }
    })

</script>
